package com.haozhen.sql

/**
  * @author haozhen
  * @email haozh@ync1.com
  * @date 2021/1/31  22:39
  */
object HIveDemo {

  def main(args: Array[String]): Unit = {
    import org.apache.spark.sql.{DataFrame, SparkSession}
    val spark: SparkSession = SparkSession.builder()
        .master("local[*]")
        .appName(this.getClass.getCanonicalName().init)
        .enableHiveSupport()
        .config("spark.sql.parquet.writeLegacyFormat","true")
        .getOrCreate()


    import org.apache.spark.sql.SaveMode
    import spark.implicits._
    import org.apache.spark.sql.functions._
    spark.sparkContext.setLogLevel("WARN")

      val frame: DataFrame = spark.sql("select * from myuser")
    frame.show()
      frame.write.mode(SaveMode.Append).saveAsTable("ods.myuser_bak")

      spark.table("ods.myuser_bak").show()
    //定义参数

    spark.close()
  }
}
